package com.zyh.file;

import java.io.File;
import java.io.IOException;

public class FileDemo3 {
    public static void main(String[] args) throws IOException {
        File file = new File("day04-code/src/com/zyh/file/a");
        if (!file.exists()){
            boolean mkdir = file.mkdir();
            System.out.println("mkdir = " + mkdir);
        }

        File file1 = new File("day04-code/src/com/zyh/file/a/b/c");
        if (!file1.exists()){
            boolean mkdirs = file1.mkdirs();
            System.out.println("mkdirs = " + mkdirs);
        }

        File file2 = new File("day04-code/src/com/zyh/file/a/b/c/Student.txt");
        if (!file2.exists()){
            file2.createNewFile();
        }
        //移动文件
        file2.renameTo(new File("day04-code/src/com/zyh/file/newStu.txt"));

        File file3 = new File("day04-code/src/com/zyh/file");
        String[] list = file3.list();
        for (String s : list) {
            System.out.println(s);
        }
        System.out.println("-----------------------");
        File[] files = file3.listFiles();
        for (File ziFile : files) {
            System.out.println(ziFile.getPath());
        }
    }
}
